<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateChatRecordsTable extends Migration
{
    /**
     * 聊天记录表
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('chat_records', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->timestamps();
            $table->unsignedInteger('sender_id')->comment('发件人id|(数据来自binding_records表id)');
            $table->unsignedInteger('addressee_id')->comment('收件人id|(数据来自binding_records表id)');
            $table->text('content')->comment('发送的内容|');
            $table->string('message_type')->comment('消息类型(json格式)|text:文本,images:图片,link:链接');
            $table->tinyInteger('is_read')->default(1)->comment('是否已读|默认为1:否,2:是');
            $table->softDeletes()->comment('软删除');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('chat_records');
    }
}
